home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / test / label.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-07  |  4.4 KB  |  161 lines

  1. //
  2. // "$Id: label.cxx,v 1.4 1999/01/07 19:17:57 mike Exp $"
  3. //
  4. // Label test program for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. #include <FL/Fl.H>
  27. #include <FL/Fl_Double_Window.H>
  28. #include <FL/Fl_Box.H>
  29. #include <FL/Fl_Hor_Value_Slider.H>
  30. #include <FL/Fl_Toggle_Button.H>
  31. #include <FL/Fl_Input.H>
  32. #include <FL/Fl_Choice.H>
  33. #include <FL/fl_draw.H>
  34.  
  35. Fl_Toggle_Button *leftb,*rightb,*topb,*bottomb,*insideb,*clipb,*wrapb;
  36. Fl_Box *text;
  37. Fl_Input *input;
  38. Fl_Hor_Value_Slider *fonts;
  39. Fl_Hor_Value_Slider *sizes;
  40. Fl_Double_Window *window;
  41.  
  42. void button_cb(Fl_Widget *,void *) {
  43.   int i = 0;
  44.   if (leftb->value()) i |= FL_ALIGN_LEFT;
  45.   if (rightb->value()) i |= FL_ALIGN_RIGHT;
  46.   if (topb->value()) i |= FL_ALIGN_TOP;
  47.   if (bottomb->value()) i |= FL_ALIGN_BOTTOM;
  48.   if (insideb->value()) i |= FL_ALIGN_INSIDE;
  49.   if (clipb->value()) i |= FL_ALIGN_CLIP;
  50.   if (wrapb->value()) i |= FL_ALIGN_WRAP;
  51.   text->align(i);
  52.   window->redraw();
  53. }
  54.  
  55. void font_cb(Fl_Widget *,void *) {
  56.   text->labelfont(int(fonts->value()));
  57.   window->redraw();
  58. }
  59.  
  60. void size_cb(Fl_Widget *,void *) {
  61.   text->labelsize(int(sizes->value()));
  62.   window->redraw();
  63. }
  64.  
  65. void input_cb(Fl_Widget *,void *) {
  66.   text->label(input->value());
  67.   window->redraw();
  68. }
  69.  
  70. void normal_cb(Fl_Widget *,void *) {
  71.   text->labeltype(FL_NORMAL_LABEL);
  72.   window->redraw();
  73. }
  74.  
  75. void symbol_cb(Fl_Widget *,void *) {
  76.   text->labeltype(FL_SYMBOL_LABEL);
  77.   if (input->value()[0] != '@') {
  78.     input->static_value("@->");
  79.     text->label("@->");
  80.   }
  81.   window->redraw();
  82. }
  83.  
  84. void shadow_cb(Fl_Widget *,void *) {
  85.   text->labeltype(FL_SHADOW_LABEL);
  86.   window->redraw();
  87. }
  88.  
  89. void embossed_cb(Fl_Widget *,void *) {
  90.   text->labeltype(FL_EMBOSSED_LABEL);
  91.   window->redraw();
  92. }
  93.  
  94. void engraved_cb(Fl_Widget *,void *) {
  95.   text->labeltype(FL_ENGRAVED_LABEL);
  96.   window->redraw();
  97. }
  98.  
  99. Fl_Menu_Item choices[] = {
  100.   {"FL_NORMAL_LABEL",0,normal_cb},
  101.   {"FL_SYMBOL_LABEL",0,symbol_cb},
  102.   {"FL_SHADOW_LABEL",0,shadow_cb},
  103.   {"FL_ENGRAVED_LABEL",0,engraved_cb},
  104.   {"FL_EMBOSSED_LABEL",0,embossed_cb},
  105.   {0}};
  106.  
  107. int main(int argc, char **argv) {
  108.   window = new Fl_Double_Window(400,400);
  109.  
  110.   input = new Fl_Input(50,0,350,25);
  111.   input->static_value("The quick brown fox jumped over the lazy dog.");
  112.   input->when(FL_WHEN_CHANGED);
  113.   input->callback(input_cb);
  114.  
  115.   sizes= new Fl_Hor_Value_Slider(50,25,350,25,"Size:");
  116.   sizes->align(FL_ALIGN_LEFT);
  117.   sizes->bounds(1,64);
  118.   sizes->step(1);
  119.   sizes->value(14);
  120.   sizes->callback(size_cb);
  121.  
  122.   fonts=new Fl_Hor_Value_Slider(50,50,350,25,"Font:");
  123.   fonts->align(FL_ALIGN_LEFT);
  124.   fonts->bounds(0,15);
  125.   fonts->step(1);
  126.   fonts->value(0);
  127.   fonts->callback(font_cb);
  128.  
  129.   Fl_Group *g = new Fl_Group(0,0,0,0);
  130.   leftb = new Fl_Toggle_Button(50,75,50,25,"left");
  131.   leftb->callback(button_cb);
  132.   rightb = new Fl_Toggle_Button(100,75,50,25,"right");
  133.   rightb->callback(button_cb);
  134.   topb = new Fl_Toggle_Button(150,75,50,25,"top");
  135.   topb->callback(button_cb);
  136.   bottomb = new Fl_Toggle_Button(200,75,50,25,"bottom");
  137.   bottomb->callback(button_cb);
  138.   insideb = new Fl_Toggle_Button(250,75,50,25,"inside");
  139.   insideb->callback(button_cb);
  140.   wrapb = new Fl_Toggle_Button(300,75,50,25,"wrap");
  141.   wrapb->callback(button_cb);
  142.   clipb = new Fl_Toggle_Button(350,75,50,25,"clip");
  143.   clipb->callback(button_cb);
  144.   g->resizable(insideb);
  145.   g->forms_end();
  146.  
  147.   Fl_Choice *c = new Fl_Choice(50,100,200,25);
  148.   c->menu(choices);
  149.  
  150.   text= new Fl_Box(FL_FRAME_BOX,100,225,200,100,input->value());
  151.   text->align(FL_ALIGN_CENTER);
  152.   window->resizable(text);
  153.   window->forms_end();
  154.   window->show(argc,argv);
  155.   return Fl::run();
  156. }
  157.  
  158. //
  159. // End of "$Id: label.cxx,v 1.4 1999/01/07 19:17:57 mike Exp $".
  160. //
  161.